<%namespace name="admin_include" file="/admin/base/include.html" />
<%inherit file="/front/base/normalbase.html"/>
<%def name="script()">
${admin_include.validationEngine()}
</%def>

<%def name="center()">
<div class="row">
    <div class="span6">
    <div class="page-header">
        <h1>
            <a href="#sd">用户注册</a>
        </h1>
    </div>
    <form id="registerform" class="form-horizontal" method="post" action="/ajaxValidateSubmit">
        <fieldset>
            <div class="control-group">
                <label class="control-label">邮箱</label>
                <div class="controls">
                    <input type="text" class="input-xlarge validate[required, maxSize[40], custom[email], ajax[ajaxUserCall]]" name="email" id="User_email_unique">
                    <p class="help-block">邮箱用于找回密码，接收订单通知等，请认真填写</p>
                    <input type="hidden" name="validation_email" value="User_email_unique"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">密码</label>
                <div class="controls">
                    <input type="password" class="input-xlarge validate[required, minSize[6], maxSize[50]]" name="password" id="password">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">确认密码</label>
                <div class="controls">
                    <input type="password" class="input-xlarge validate[required, equals[password]]" name="password">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">验证码</label>
                <div class="controls">
                    <input type="text" class="input-small validate[required]" name="captcha">
                    <p class="help-block"><img id="captcha" src="/captcha"/>&nbsp;<a id="changeCaptcha" href="#">换一个</a></p>
                </div>
            </div>
            <div class="form-actions">
                <input type="hidden" name="form.submitted" value="save"/>
                <button class="btn btn-primary" type="submit">注&nbsp;册</button>
            </div>
        </fieldset>
    </form>
    </div>
</div>
<script type="text/javascript">
function ajaxValidationCallback(status, form, json, options)
{
    if(status)
    {
        form.attr('action', '${request.url}');
        form.validationEngine('detach');
        form.submit();
    }
}
$(document).ready(function(){
    $('#changeCaptcha').click(function(){
        $('#captcha').attr('src', '/captcha?' + Math.random()*1000);
    })

    $('#registerform').validationEngine({
            ajaxFormValidation: true,
            onAjaxFormComplete: ajaxValidationCallback,
    })
})
</script>
</%def>
